﻿using BizBrowser.RPT;
using CefSharp.WinForms;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BizBrowser.JS
{
    public class JsInterface
    {
        ChromiumWebBrowser _browser;
        MainForm _mainForm;
        public JsInterface(ChromiumWebBrowser _browser,MainForm _mainForm)
        {
            this._browser = _browser;
            this._mainForm = _mainForm;
        }
        /// <summary>
        /// 顶尖电子秤传秤
        /// </summary>
        /// <param name="tempName"></param>
        /// <param name="hfJson"></param>
        /// <param name="detailJson"></param>
        public void aclasSend(String ips, String pluLines)
        {
            _mainForm.AclasSend(ips,pluLines);
        }

        public void printPreview(String tempName,String hfJson,String detailJson)
        {
            _mainForm.Preview(tempName,hfJson,detailJson);
        }

        public string print(String tempName, String hfJson, String detailJson)
        {
           return _mainForm.Print(tempName,hfJson,detailJson);
        }

        public void design()
        {
            _mainForm.Design("test.frx");
        }

        public String getPrintList()
        {
            return PrintUtil.getJsonPrintList().ToString();
        }

        public String callApp(String appName, String param,String currentBase)
        {
            try
            {
                if ("1".Equals(currentBase))
                {
                    Process.Start(Path.Combine(Application.StartupPath, appName), param);
                }
                else
                {
                    Process.Start(appName, param);
                }
            }
            catch(Exception ex)
            {
                return ex.Message;
            }
            return "";
            
        }

    }
}
